<?php
namespace app\api\controller\v1;
use app\api\controller\Common;

class Content extends Common{
	var $modelDb;
	public function _initialize(){
		parent::_initialize();
		$this->modelDb = model("Content");
	}
	//获取筛选条件   海报、h5海报、精彩文章  	4:品牌海报，6：经销商海报
	public function get_filt(){
		$poster_filt = [['filtid'=>0, 'name'=>'全部'], ['filtid'=>-4, 'name'=>'品牌海报'], ['filtid'=>-6, 'name'=>'经销商海报']];
		$content_filt = [['filtid'=>0, 'name'=>'全部'], ['filtid'=>-4, 'name'=>'品牌文章'], ['filtid'=>-6, 'name'=>'经销商文章']];
		if ($this->uinfo['roleid'] == 5) {
			$list = model('AdminUser')->where('puserid', 2)->where('roleid', 6)->field('userid as filtid, realname as name')->order('userid asc')->select();
			foreach ($list as $v) {
				$poster_filt[] = $v;
				$content_filt[] = $v;
			}
		}
		return $this->app_success(['poster_filt'=>$poster_filt, 'content_filt'=>$content_filt]);
	}
	public function index(){
    	$list = $this->modelDb->list_datas($this->postData, $this->uinfo);
    	if ($list === false) {
    		return $this->app_error();
    	}
    	return $this->app_success($list);
    }
    public function poster_list(){
    	$list = model('Poster')->list_datas($this->postData, $this->uinfo);
    	if ($list === false) {
    		return $this->app_error();
    	}
    	return $this->app_success($list);
    }
}